<?php

//
//  Copyright (C) 2004-2006  Autodesk, Inc.
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of version 2.1 of the GNU Lesser
//  General Public License as published by the Free Software Foundation.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//

?>

<?php
require_once("config.php");
require_once("utils.php");
require_once(ROOT_DIR_CLASES.'/cCliente.php'); 
require_once 'JSON.php';

class ConsultaPublicidad
{
   	var $publicidadId;
	var $canCheck;
}

class QueryConsultaPublicidad
{
	private $args = null;
	
	function __construct($args)
	{
		$this->args = $args;
	}

	function Execute()
	{
		// PASAMOS LOS ARGUMENTOS A VARIABLES LOCALES
		$tablaId = $this->args['tablaId'];
		$objetivo = $this->args['objetivo'];

		//--------------------------------------	
		
		// INSTANCIAMOS UN OBJETO CONSULTAPUBLICIDAD Y LE SETEAMOS SUS ATRIBUTOS POR DEFECTO
		$response = new ConsultaPublicidad();
		$response->publicidadId = -1;
		$response->canCheck = 0;

		// LE PEDIMOS A BYKOMCLIENTE QUE VERIFIQUE LA EXISTENCIA DE PUBLICIDADES PARA EL USUARIO
  		$publicidades = BykomCliente::Consulta_Publicidad($tablaId, $objetivo);
		if( $publicidades->cantidad() > 0 )
		{
			$response->publicidadId = $publicidades->campo('publicidadId', 0);
			$response->canCheck = $publicidades->campo('canCheck', 0);
		}

		// DEVOLVEMOS EL OBJETO CONSULTAPUBLICIDAD
		return $response;
	}
}
?>